package cc.yiueil.ceate;

/**
 * CreateThread1 创建线程的方式1
 * 继承 Thread 类, 重写run()方法
 *
 * @version 1.0
 */
public class CreateThread1 {
    public static void main(String[] args) {
        System.out.println("start main thread!");
        Thread thread1 = new CustomThread();
        Thread thread2 = new CustomThread();
        // 启动新线程
        thread1.start();
        thread2.start();
        System.out.println("end main thread!");
    }
}

class CustomThread extends Thread {
    @Override
    public void run() {
        System.out.println("start new thread!");
         try {
             Thread.sleep(1000);
         } catch (InterruptedException e) {
             e.printStackTrace();
         }
        System.out.println("end new thread!");
    }
}


